#include "Skybox.h"
#include "MatrixHelper.h"
#include "GraphicsDeviceManager.h"
#include "BoundingBoxRenderer.h"
#include "TextureManager.h"

Skybox::Skybox()
{
}


Skybox::~Skybox()
{
}

Texture2D* Skybox::GetTexture()
{
	return m_pTexture;
}

void Skybox::SetTexture(Texture2D* texture)
{
	m_pTexture = texture;
}

void Skybox::LoadContent()
{
	m_pTexture = TextureManager::Load("Debug/Error");
}

void Skybox::Draw()
{
	glPushMatrix();

	Matrix view;

	glGetFloatv(GL_MODELVIEW_MATRIX, view);

	MatrixHelper::SetTranslation(view, Vector3f::Zero);

	glDisable(GL_DEPTH_TEST);
	//GraphicsDeviceManager::BindTexture(m_pTexture);
	
	// TODO: Use textures and a proper drawing method.
	// TODO: Create a proper standard for skybox textures.
	BoundingBoxRenderer::Draw(BoundingBox(Vector3f(-2.0f), Vector3f(2.0f)));

	//GraphicsDeviceManager::UnbindTexture();
	glEnable(GL_DEPTH_TEST);

	glPopMatrix();

}

void Skybox::UnloadContent()
{
	TextureManager::Unload(m_pTexture);
}